package model

import (
	"time"
)

// Wave 表示一个波次
type Wave struct {
	ID                string     `gorm:"primaryKey" json:"id"`
	DeliveryStationID string     `json:"delivery_station_id"`
	Status            WaveStatus `json:"status"`
	StartTime         time.Time  `json:"start_time"`
	EndTime           time.Time  `json:"end_time"`
	CreatedAt         time.Time  `json:"created_at"`
	UpdatedAt         time.Time  `json:"updated_at"`
	Orders            []Order    `gorm:"many2many:wave_orders;" json:"orders"`
}

// WaveOrder 表示波次和订单的关联关系
type WaveOrder struct {
	ID        string    `gorm:"primaryKey" json:"id"`
	WaveID    string    `gorm:"index" json:"wave_id"`
	OrderID   string    `gorm:"index" json:"order_id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

// WaveQuery 波次查询参数
type WaveQuery struct {
	Status            WaveStatus `json:"status,omitempty"`
	DeliveryStationID string     `json:"delivery_station_id,omitempty"`
	StartTime         time.Time  `json:"start_time,omitempty"`
	EndTime           time.Time  `json:"end_time,omitempty"`
	Priority          int        `json:"priority,omitempty"`
	CreatedAfter      time.Time  `json:"created_after,omitempty"`
	CreatedBefore     time.Time  `json:"created_before,omitempty"`
	Page              int        `json:"page"`
	PageSize          int        `json:"page_size"`
}

// TableName 指定表名
func (Wave) TableName() string {
	return "waves"
}

// TableName 指定表名
func (WaveOrder) TableName() string {
	return "wave_orders"
}
